package com.itheima.d9_interface_demo.CaseDemo;

import java.util.ArrayList;

/**
 * @ClassName StudentOperatorImpl1
 * @Author 16799
 * @Date 2025/7/10 21:49
 * @Version 1.0
 * @Description TODO
 **/
public class StudentOperatorImpl1 implements StudentOperator{
    @Override
    public void printAllInfo(ArrayList<Student> students) {
        System.out.println("========全班学生的数据=======");
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            System.out.println("姓名：" + s.getName() + ", 性别：" + s.getSex() + ", 成绩：" + s.getScore());
        }
        System.out.println("==================");
    }

    @Override
    public void printAverageScore(ArrayList<Student> students) {
        double allScore = 0;
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            allScore+=s.getScore();
        }
        System.out.println("平均分：" + (allScore) / students.size());

    }
}
